﻿using StarPizza.Model.Core;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StarPizza.ViewModel.ManagerSystem
{
    class CashAdministrator : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        CashRegister cashRegister;
        public CashAdministrator(CashRegister cashRegister)
        {
            this.cashRegister = cashRegister;
            cashRegister.CashChanged += cashRegister_CashChanged;
        }
        public int Cash
        {
            get { return cashRegister.Cash; }
            set
            {
                cashRegister.Cash = value;
                OnPropertyChanged("Cash");
            }
        }
        private int cashDifference;
        public int CashDifference
        {
            get { return cashDifference; }
            set
            {
                if (value != cashDifference)
                {
                    cashDifference = value;
                    OnPropertyChanged("CashDifference");
                }
            }
        }
        void cashRegister_CashChanged(int newCash)
        {
            OnPropertyChanged("Cash");
        }
        public void AdministerChange()
        {
            Cash += CashDifference;
        }
    }
}
